<template>
  <div class="main">
    <!--logo和项目名-->
    <div class="left_box">
      <img alt="" src="../assets/1.jpg" />
      <span>生产优化平台</span>
    </div>
    <!--右侧姓名和头像-->
    <div class="right_box">
      <span style="font-size: small">用户名</span>
      <el-dropdown>
        <span class="el-dropdown-link">
          <el-avatar :size="30" style="margin: 12px 10px 0 15px"></el-avatar>
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item icon="el-icon-house"   @click.native="backHome"
          >首页</el-dropdown-item>
          <el-dropdown-item icon="el-icon-switch-button"  @click.native="logout"
            >退出登录</el-dropdown-item
          >
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </div>
</template>

<script>
export default {
  methods: {
    backHome () {
      this.$router.push('/home')
    },
    logout () {
      window.localStorage.clear()
      this.$router.push('/login')
    }
  }
}
</script>

<style scoped>
.main {
  position: relative;
  left: 0;
}
.left_box {
  align-items: center;
  position: absolute;
}
.left_box img {
  width: 50px;
  height: 50px;
  border-radius: 25px;
  margin: auto auto 5px 25px;
}
.right_box {
  align-items: center;
  position: absolute;
  right: 0;
}
</style>
